home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / _PROPER.PRG < prev    next >
Text File  |  1993-05-04  |  2KB  |  61 lines

  1. FUNCTION _Proper            && Convert a String to Proper Name Format
  2. PARAMETERS pc_string
  3. *--------------------------------------------------------------------
  4. * NAME
  5. *   _PROPER - Convert a string to proper name format.
  6. *
  7. * SYNOPSIS
  8. *   _PROPER( pc_string )
  9. *
  10. * DESCRIPTION
  11. *   _PROPER returns its argument with the first letter
  12. *   of each word capitalized, and all other letters in
  13. *   lower case.  Note that each word must be separated
  14. *   by at least one empty space.
  15. *
  16. * PARAMETER
  17. *   pc_string = the string to convert
  18. *
  19. * EXAMPLE
  20. *
  21. *   ? _PROPER( "smith" )                && Returns "Smith"
  22. *
  23. *   ? _PROPER( "joe foo" )              && Is now "Joe Foo"
  24. *
  25. *   ? _PROPER( "joe,foo" )              && Returns "Joe,foo"
  26. *
  27. * LIMITATIONS
  28. *   Note that _PROPER() may not give acceptable results
  29. *   on surnames such as "McDonald," "de la Vega" or
  30. *   "ffolkes."
  31. *
  32. * SEE ALSO:
  33. *   UPPER(), LOWER()
  34. *
  35. *--------------------------------------------------------------------
  36.  
  37.   PRIVATE lc_result, ln_length, ln_posit
  38.  
  39.   lc_result = LOWER( TRIM( m->pc_string ))
  40.   ln_posit  = 2
  41.   ln_length = LEN( m->lc_result )
  42.  
  43.   IF SUBSTR( m->lc_result, 1, 1 ) <> ' '
  44.     lc_result = STUFF( m->lc_result, 1, 1, ;
  45.                 UPPER( SUBSTR( m->lc_result, 1, 1 ) ) )
  46.   ENDIF
  47.  
  48.   DO WHILE m->ln_posit <= m->ln_length
  49.     IF SUBSTR( m->lc_result, m->ln_posit - 1, 1 ) = ' '
  50.       lc_result = STUFF( m->lc_result,;
  51.                          m->ln_posit,;
  52.                          1,;
  53.                          UPPER( SUBSTR( m->lc_result, m->ln_posit, 1 ) ) )
  54.     ENDIF
  55.     ln_posit = m->ln_posit + 1
  56.   ENDDO
  57.  
  58. RETURN( m->lc_result )
  59. *-- EOF: _Proper( pc_string )
  60.  
  61.